package easy;

import java.util.HashMap;
import java.util.Map;

public class Solution_LCP_39 {
    public int minimumSwitchingTimes(int[][] source, int[][] target) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int[] ints : target) {
            for (int anInt : ints) {
                Integer count = map.getOrDefault(anInt, 0);
                count++;
                map.put(anInt, count);
            }
        }
        for (int[] ints : source) {
            for (int anInt : ints) {
                if (map.containsKey(anInt)) {
                    map.put(anInt, map.get(anInt) - 1);
                }
            }
        }
        int res = 0;
        for (Integer key : map.keySet()) {
            if (map.get(key) > 0) {
                res += map.get(key);
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution_LCP_39 model = new Solution_LCP_39();
        System.out.println(model.minimumSwitchingTimes(new int[][]{{1, 3}, {5, 4}}, new int[][]{{3, 1}, {6, 5}}));
        System.out.println(model.minimumSwitchingTimes(new int[][]{{1, 2, 3}, {3, 4, 5}}, new int[][]{{1, 3, 5}, {2, 3, 4}}));
    }
}
